﻿using System.Collections.Generic;
using Shell.Build;

namespace Shell.Advanced
{
    class ShellRegistrationRecorder : IShellRegistrationHolder
    {
        private readonly List<object> registrations;

        public ShellRegistrationRecorder()
        {
            this.registrations = new List<object>();
        }

        public IEnumerable<object> Registrations
        {
            get { return this.registrations; }
        }

        public void Record(object registration)
        {
            lock (this.registrations)
            {
                if (this.registrations.Contains(registration))
                {
                    this.registrations.Remove(registration);
                }
                this.registrations.Add(registration);
            }
        }

        public void UnRecord(object registration)
        {
            lock (this.registrations)
            {
                if (this.registrations.Contains(registration))
                {
                    this.registrations.Remove(registration);
                }
            }
        }
    }
}
